# src files
list(
  APPEND
  LIBHEVCENC_SRCS
  "${HEVC_ROOT}/encoder/bit_allocation.c"
  "${HEVC_ROOT}/encoder/cbr_buffer_control.c"
  "${HEVC_ROOT}/encoder/common_rom.c"
  "${HEVC_ROOT}/encoder/convert_float_to_fix.c"
  "${HEVC_ROOT}/encoder/est_sad.c"
  "${HEVC_ROOT}/encoder/fixed_point_error_bits.c"
  "${HEVC_ROOT}/encoder/frame_info_collector.c"
  "${HEVC_ROOT}/encoder/hme_coarse.c"
  "${HEVC_ROOT}/encoder/hme_common_utils.c"
  "${HEVC_ROOT}/encoder/hme_err_compute.c"
  "${HEVC_ROOT}/encoder/hme_fullpel.c"
  "${HEVC_ROOT}/encoder/hme_function_selector.c"
  "${HEVC_ROOT}/encoder/hme_globals.c"
  "${HEVC_ROOT}/encoder/hme_interface.c"
  "${HEVC_ROOT}/encoder/hme_refine.c"
  "${HEVC_ROOT}/encoder/hme_search_algo.c"
  "${HEVC_ROOT}/encoder/hme_subpel.c"
  "${HEVC_ROOT}/encoder/hme_utils.c"
  "${HEVC_ROOT}/encoder/ihevce_bitstream.c"
  "${HEVC_ROOT}/encoder/ihevce_bs_compute_ctb.c"
  "${HEVC_ROOT}/encoder/ihevce_buffer_que.c"
  "${HEVC_ROOT}/encoder/ihevce_cabac.c"
  "${HEVC_ROOT}/encoder/ihevce_cabac_cu_pu.c"
  "${HEVC_ROOT}/encoder/ihevce_cabac_rdo.c"
  "${HEVC_ROOT}/encoder/ihevce_cabac_tu.c"
  "${HEVC_ROOT}/encoder/ihevce_chroma_had_satd.c"
  "${HEVC_ROOT}/encoder/ihevce_cmn_utils_instr_set_router.c"
  "${HEVC_ROOT}/encoder/ihevce_coarse_me_pass.c"
  "${HEVC_ROOT}/encoder/ihevce_common_utils.c"
  "${HEVC_ROOT}/encoder/ihevce_deblk.c"
  "${HEVC_ROOT}/encoder/ihevce_decomp_pre_intra_pass.c"
  "${HEVC_ROOT}/encoder/ihevce_dep_mngr.c"
  "${HEVC_ROOT}/encoder/ihevce_enc_cu_recursion.c"
  "${HEVC_ROOT}/encoder/ihevce_enc_loop_inter_mode_sifter.c"
  "${HEVC_ROOT}/encoder/ihevce_enc_loop_pass.c"
  "${HEVC_ROOT}/encoder/ihevce_enc_loop_utils.c"
  "${HEVC_ROOT}/encoder/ihevce_enc_sbh_funcs.c"
  "${HEVC_ROOT}/encoder/ihevce_enc_subpel_gen.c"
  "${HEVC_ROOT}/encoder/ihevce_encode_header.c"
  "${HEVC_ROOT}/encoder/ihevce_encode_header_sei_vui.c"
  "${HEVC_ROOT}/encoder/ihevce_entropy_cod.c"
  "${HEVC_ROOT}/encoder/ihevce_entropy_interface.c"
  "${HEVC_ROOT}/encoder/ihevce_error_check.c"
  "${HEVC_ROOT}/encoder/ihevce_frame_process.c"
  "${HEVC_ROOT}/encoder/ihevce_frame_process_utils.c"
  "${HEVC_ROOT}/encoder/ihevce_function_selector.c"
  "${HEVC_ROOT}/encoder/ihevce_global_tables.c"
  "${HEVC_ROOT}/encoder/ihevce_had_satd.c"
  "${HEVC_ROOT}/encoder/ihevce_hle_interface.c"
  "${HEVC_ROOT}/encoder/ihevce_hle_q_func.c"
  "${HEVC_ROOT}/encoder/ihevce_inter_pred.c"
  "${HEVC_ROOT}/encoder/ihevce_ipe_instr_set_router.c"
  "${HEVC_ROOT}/encoder/ihevce_ipe_pass.c"
  "${HEVC_ROOT}/encoder/ihevce_lap_interface.c"
  "${HEVC_ROOT}/encoder/ihevce_me_instr_set_router.c"
  "${HEVC_ROOT}/encoder/ihevce_me_pass.c"
  "${HEVC_ROOT}/encoder/ihevce_memory_init.c"
  "${HEVC_ROOT}/encoder/ihevce_multi_thrd_funcs.c"
  "${HEVC_ROOT}/encoder/ihevce_mv_pred.c"
  "${HEVC_ROOT}/encoder/ihevce_mv_pred_merge.c"
  "${HEVC_ROOT}/encoder/ihevce_nbr_avail.c"
  "${HEVC_ROOT}/encoder/ihevce_plugin.c"
  "${HEVC_ROOT}/encoder/ihevce_profile.c"
  "${HEVC_ROOT}/encoder/ihevce_rc_interface.c"
  "${HEVC_ROOT}/encoder/ihevce_recur_bracketing.c"
  "${HEVC_ROOT}/encoder/ihevce_sao.c"
  "${HEVC_ROOT}/encoder/ihevce_stasino_helpers.c"
  "${HEVC_ROOT}/encoder/ihevce_sub_pic_rc.c"
  "${HEVC_ROOT}/encoder/ihevce_sys_api.c"
  "${HEVC_ROOT}/encoder/ihevce_tile_interface.c"
  "${HEVC_ROOT}/encoder/ihevce_trace.c"
  "${HEVC_ROOT}/encoder/ihevce_tu_tree_selector.c"
  "${HEVC_ROOT}/encoder/init_qp.c"
  "${HEVC_ROOT}/encoder/mb_model_based.c"
  "${HEVC_ROOT}/encoder/osal.c"
  "${HEVC_ROOT}/encoder/osal_cond_var.c"
  "${HEVC_ROOT}/encoder/osal_error.c"
  "${HEVC_ROOT}/encoder/osal_mutex.c"
  "${HEVC_ROOT}/encoder/osal_semaphore.c"
  "${HEVC_ROOT}/encoder/osal_thread.c"
  "${HEVC_ROOT}/encoder/picture_type.c"
  "${HEVC_ROOT}/encoder/rate_control_api.c"
  "${HEVC_ROOT}/encoder/rc_rd_model.c"
  "${HEVC_ROOT}/encoder/rc_rd_model_fix.c"
  "${HEVC_ROOT}/encoder/rc_sad_acc.c"
  "${HEVC_ROOT}/encoder/sqrt_interp.c"
  "${HEVC_ROOT}/encoder/var_q_operator.c"
  "${HEVC_ROOT}/encoder/vbr_storage_vbv.c"
  "${HEVC_ROOT}/encoder/vbr_str_prms.c")

include_directories(${HEVC_ROOT}/encoder)

# arm/x86 sources
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}"
                                                     STREQUAL "aarch32")
  list(
    APPEND
    LIBHEVCENC_ASMS
    "${HEVC_ROOT}/encoder/arm/ihevce_coarse_layer_sad_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_coarse_layer_sad_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_common_utils_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_common_utils_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_copy_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_copy_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_decomp_pre_intra_pass_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_decomp_pre_intra_pass_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_had_compute_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_had_compute_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_hme_utils_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_hme_utils_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_itrans_recon_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_itrans_recon_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_me_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_me_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_sad_compute_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_sad_compute_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_scale_by_2_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_scale_by_2_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_scan_coeffs_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_scan_coeffs_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_ssd_and_sad_calculator_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_ssd_and_sad_calculator_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_ssd_calculator_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_ssd_calculator_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_subpel_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_subpel_neon.c"
    "${HEVC_ROOT}/encoder/arm/ihevce_subpel_neon.c")

  include_directories(${HEVC_ROOT}/encoder/arm ${HEVC_ROOT}/encoder)
endif()

add_library(libhevcenc STATIC ${LIBHEVC_COMMON_SRCS} ${LIBHEVC_COMMON_ASMS}
                              ${LIBHEVCENC_ASMS} ${LIBHEVCENC_SRCS})

target_compile_definitions(libhevcenc PRIVATE N_MB_ENABLE
                                              ENABLE_MAIN_REXT_PROFILE)
